import java.util.LinkedList;
import java.util.Queue;

public class Leetcode1716 {
    public static void main(String[] args) {
        System.out.println(totalMoney(4));
    }

    private static final int WEEK_MONEY = 28;

    private static final int[] DAY_MONEY = {0, 1, 3, 6, 10, 15, 21, 28};

    public static int totalMoney(int n) {
        int ordinaryMoney = n / 7 * WEEK_MONEY;
        int manyMoney = ((n / 7 - 1) * (n / 7) / 2) * 7;
        int lastMoney = DAY_MONEY[n % 7] + (n % 7 * (n / 7));

        return ordinaryMoney + manyMoney + lastMoney;
    }

}
